@layout("/common/_container.html"){
<link href="https://pynnn.oss-cn-hangzhou.aliyuncs.com/doctor_template.css?v=20200628" rel="stylesheet">
<div style="display: none"><input type="hidden" id="valValue" value="${val}"></div>
<div style="display: none"><input type="hidden" id="checkid" value=""></div>
<div style="height: 100%;">
    <div style="background: #6090b8;color: white;padding: 5px 10px;">病例模板</div>
    <div style="display: flex;height: calc(100% - 78px);padding: 20px 25px 20px 0;">
        <div id="templateBox">
            <ul style="padding-left: 22px;">
                <li>
                    <span style="color: #00A8CB" class="glyphicon glyphicon-folder-open"></span><span style="margin-left: 12px;font-weight: bold;">我的模板</span>
                </li>
                @for(item in reMap){
                <li class="oneClass" style="margin: 5px 3px;">
                    <span style="color: #00A8CB" class="glyphicon glyphicon-plus-sign"></span>
                    <span style="color: #00A8CB;display: none" class="glyphicon glyphicon-minus-sign"></span>
                    <span style="margin-left: 5px;">${item.key}</span>
                    <ul style="display: none;padding-left: 20px;">
                        @for(str in item.value){
                        <li class="twoClass" style="margin: 3px 0;">
                            <span style="color: #00A8CB" class="glyphicon glyphicon-plus-sign"></span>
                            <span style="color: #00A8CB;display: none" class="glyphicon glyphicon-minus-sign"></span>
                            <span>${str.key}</span>
                            <ul style="display: none;padding-left: 20px;">
                                @for(thr in str.value){
                                <li class="thrClass" style="margin: 3px 0;">
                                    <span style="color: #00A8CB" class="glyphicon glyphicon-file"></span>
                                    <span style="cursor: pointer;" onclick="dataShow('${thr.id}')">${thr.casename}</span>
                                </li>
                                @}
                            </ul>
                        </li>
                        @}
                    </ul>
                </li>
                @}
            </ul>
        </div>
        <div id="template" style="height: 100%">
            <div style="position: relative;height: 48px;border-bottom: 1px solid #dddddd">
                <div class="absolutes choice">初诊模板</div>
                <div class="absolutes choices">复诊模板</div>
                <h3 style="margin: 0;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);font-size: 16px;" id="templateName"></h3>
            </div>
            <div style="overflow-y: auto;flex: 9;padding-bottom: 10px;">
                <div class="content-li choice">
                    <span>主述：</span><span id="zhushu"></span>
                </div>
                <div class="content-li choices">
                    <span>复诊：</span><span id="zhushu"></span>
                </div>
                <div class="content-li">
                    <span>现病史：</span><span id="nowMedicalHistory"></span>
                </div>
                <div class="content-li">
                    <span>既往史：</span><span id="beforeMedicalHistory"></span>
                </div>
                <div class="content-li">
                    <span>口腔检查：</span><span id="mouthCheck"></span>
                </div>
                <div class="content-li">
                    <span>辅助检查：</span><span id="auxiliaryCheck"></span>
                </div>
                <div class="content-li">
                    <span>诊断：</span><span id="diagnose"></span>
                </div>
                <div class="content-li">
                    <span>治疗计划：</span><span id="remedyPlan"></span>
                </div>
                <div class="content-li">
                    <span>处置：</span><span id="dispose"></span>
                </div>
                <div class="content-li">
                    <span>医嘱：</span><span id="doctorAdvice"></span>
                </div>
            </div>
        </div>
    </div>
    <div class="btnBox">
        <button type="button" class="btn" onclick="contentShow()">确定</button>
        <button type="button" class="btn" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));">取消</button>
        <span style="cursor: pointer;"><button type="button" class="btn" onclick="deleteShow()">删除模板</button></span>
    </div>
</div>
<script>
    $(function () {
       if($("#valValue").val() == 1){
           $(".choices").hide()
       }else if($("#valValue").val() == 2){
           $(".choice").hide()
       }
    });
    $("#templateBox").on('click','.oneClass',function () {
        $(this).children('.glyphicon-plus-sign').toggle();
        $(this).children('.glyphicon-minus-sign').toggle();
        $(this).children('ul').toggle();
    });
    $("#templateBox").on('click','.twoClass',function (e) {
        e.stopPropagation();
        $(this).children('.glyphicon-plus-sign').toggle();
        $(this).children('.glyphicon-minus-sign').toggle();
        $(this).children('ul').toggle();
    });
    $("#templateBox").on('click','.thrClass span',function (e) {
        e.stopPropagation();
        $("span").removeClass('templateStyle');
        $(this).addClass('templateStyle');
    });
    dataShow = function (id) {
        $("#checkid").val(id);
        $.ajax({
            type: "POST",
            url: Feng.ctxPath + "/doctorLooked/getCaseContent",
            data: {
                "id":id
            },
            dataType: "json",
            success: function (data) {
                $("#templateName").html(data.casename);
                $("#zhushu").html(data.zhushu);
                $("#nowMedicalHistory").html(data.nowMedicalHistory);
                $("#beforeMedicalHistory").html(data.beforeMedicalHistory);
                $("#mouthCheck").html(data.mouthCheck);
                $("#auxiliaryCheck").html(data.auxiliaryCheck);
                $("#diagnose").html(data.diagnose);
                $("#remedyPlan").html(data.remedyPlan);
                $("#dispose").html(data.dispose);
                $("#doctorAdvice").html(data.doctorAdvice);
            }
        });
    };
    deleteShow = function () {
        var id= $("#checkid").val();
        if(confirm("确认删除模板吗?")){
            if(id==null || id=="" || id==undefined){
                alert("请选择要删除的模板")
                return;
            }
            $.ajax({
                type: "POST",
                url: Feng.ctxPath + "/doctorLooked/deleteCaseContent",
                data: {
                    "id":id
                },
                dataType: "json",
                success: function (data) {
                    if(data==-1){
                        alert("亲，不能取消其他医生的模板！");
                        return;
                    }else{
                        Feng.success('操作成功!');
                    }
                }
            });
        }
    };
    contentShow = function () {
        window.parent.document.getElementById("zhushu").value = $("#zhushu").html();
        window.parent.document.getElementById("nowMedicalHistory").value = $("#nowMedicalHistory").html();
        window.parent.document.getElementById("beforeMedicalHistory").value = $("#beforeMedicalHistory").html();
        window.parent.document.getElementById("doctorAdvice").value = $("#doctorAdvice").html();
        window.parent.document.getElementsByClassName("remarks1")[0].value = $("#mouthCheck").html();
        window.parent.document.getElementsByClassName("remarks2")[0].value = $("#auxiliaryCheck").html();
        window.parent.document.getElementsByClassName("remarks3")[0].value = $("#diagnose").html();
        window.parent.document.getElementsByClassName("remarks4")[0].value = $("#remedyPlan").html();
        window.parent.document.getElementsByClassName("remarks5")[0].value = $("#dispose").html();
        parent.layer.close(parent.layer.getFrameIndex(window.name))
    }
</script>
@}